using Common.Commands;
using Common.Commands.FolderCommands;
using Core.Domain.Model;
using Dto.ApiResponses.FolderResponses;
using Sanelib.DataOperation;

namespace Core.Processors.FolderProcessors
{
    public class AddFolderProcessor : ICommandProcessor<AddFolder>
    {
        private readonly IRepository<Folder> _repository;

        public AddFolderProcessor(IRepository<Folder> repository)
        {
            _repository = repository;
        }

        public dynamic Process(AddFolder command)
        {
            var folder = new Folder
            {
                Id = command.Id,
                Name = command.Name,
                ReferenceId = command.ReferenceId,
                ReferenceName = command.ReferenceName,
                Tags = command.Tags,
                EntityType = command.EntityType,
                Description = command.Description,
                ImageData = command.ImageData,
                CreatedBy = command.UserId
            };

            _repository.Add(folder);

            return new FolderResponse
            {
                Id = command.Id,
                Name = command.Name,
                Description = command.Description,
                ImageData = command.ImageData
            };
        }
    }
}
